package com.cqhfan.imservice.controller;

import com.cqhfan.imservice.service.ChatListService;
import com.cqhfan.pojo.im.po.ChatList;
import com.cqhfan.pojo.im.vo.ChatListVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 眭传洪
 * @create 2025-08-17 0:07
 */
@RestController
@RequestMapping("/chatList")
@RequiredArgsConstructor
public class ChatListController {

    private final ChatListService chatListService;

    /**
     * 创建聊天列表项
     */
    @PostMapping("/createPrivateChatItem")
    public String createPrivateChatItem(@RequestBody ChatList body) {
        return chatListService.createPrivateChatItem(body);
    }

    @GetMapping("/getSingleChatInfo/{receiveUserId}")
    public ChatListVO getSingleChatInfo(@PathVariable("receiveUserId") Long receiveUserId) {
        return chatListService.getSingleChatInfo(receiveUserId);
    }

    /**
     * 获取我的聊天列表
     */
    @GetMapping("/listChatList")
    public List<ChatListVO> listChatList() {
        return chatListService.listChatList();
    }

    /**
     修改当前所在的聊天框，方便设置是否已读
     */
    @PutMapping("/updateCurrentChatRoomReadStatus/{chatListId}")
    public void updateCurrentChatRoomReadStatus(@PathVariable("chatListId") Long chatListId) {
        chatListService.updateCurrentChatRoomReadStatus(chatListId);
    }

}
